package com.struts2.action;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionSupport;
import com.struts2.model.Category;
import com.struts2.model.Color;
import com.struts2.model.Designer;
import com.struts2.model.Gender;
import com.struts2.model.Product_item;
import com.struts2.model.Product_line;
import com.struts2.model.Season;
import com.struts2.model.Type;
import com.struts2.service.ProductListService;
import com.struts2.service.ProductUploadService;

public class ProductUploadAction extends ActionSupport implements SessionAware{

	private static final long serialVersionUID = 1L;
	
	private List<Product_item> product_items;
	private Product_line product_lines;
	private List<String> category;
	private List<String> type;
	private List<String> gender;
	private List<String> season;
	private List<String> designerList;
	private String categoryselected;
	private String typeselected;
	private String genderselected;
	private String seasonselected;
	private String name;
	private String description;
	private int price;
	private String designername;
	private String testing;
	private Designer designer;
	private Product_line productLine;
	private Category categoryModel;
	private Type typeModel;
	private Gender genderModel;
	private Season seasonModel;
	
	private List<Color> color;
	private int sizeNo;
	private int colorNo;
	private int pid;
	
	private Map<String, Object> session;
	@Override
	public void setSession(Map<String, Object> session) {
		this.session = session;
	}
	
	public String toUpload() {
		/*ProductUploadService productUploadService = new ProductUploadService();
		gender = new ArrayList<String>();
		gender = productUploadService.getGender(gender);
		category = new ArrayList<String>();
		category = productUploadService.getCategory(category);
		type = new ArrayList<String>();
		type = productUploadService.getType(type);
		season = new ArrayList<String>();
		season = productUploadService.getSeason(season);
		System.out.println(gender);
		System.out.println(category);
		System.out.println(type);
		System.out.println(season);*/
		return SUCCESS;
	}
	
	public String uploadProductLine(){
		System.out.println("uploadProductLine called");
		System.out.println("designername" + designername);
		productLine = new Product_line();
		ProductUploadService productUploadService = new ProductUploadService();
		genderModel = productUploadService.genderModel(genderModel, genderselected);
		categoryModel = productUploadService.categoryModel(categoryModel, categoryselected);
		typeModel = productUploadService.typeModel(typeModel, typeselected);
		seasonModel = productUploadService.seasonModel(seasonModel, seasonselected);
		designer = productUploadService.designerModel(designer, designername);
		productLine = productUploadService.insert(productLine, genderModel, categoryModel, typeModel, seasonModel, designer, name, description, price);
		System.out.println(productLine.getId());
		setPid(productLine.getId());
		setSizeNo(productUploadService.getSizeNo(sizeNo)+1);
		setColorNo(productUploadService.getColorNo(colorNo)+1);
		System.out.println(sizeNo);
		System.out.println(colorNo);
		color = new ArrayList<Color>();
		color = productUploadService.getColor(color);
		System.out.println(color);
		return SUCCESS;
	}
	
	
	public List<Product_item> getProduct_items() {
		return product_items;
	}
	public void setProduct_items(List<Product_item> product_items) {
		this.product_items = product_items;
	}
	public Product_line getProduct_lines() {
		return product_lines;
	}
	public void setProduct_lines(Product_line product_lines) {
		this.product_lines = product_lines;
	}
	public List<String> getCategory() {
		return category;
	}
	public void setCategory(List<String> category) {
		this.category = category;
	}
	public List<String> getType() {
		return type;
	}
	public void setType(List<String> type) {
		this.type = type;
	}
	public List<String> getGender() {
		return gender;
	}
	public void setGender(List<String> gender) {
		this.gender = gender;
	}
	public List<String> getSeason() {
		return season;
	}
	public void setSeason(List<String> season) {
		this.season = season;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public int getPrice() {
		return price;
	}
	public void setPrice(int price) {
		this.price = price;
	}

	public String getCategoryselected() {
		return categoryselected;
	}

	public void setCategoryselected(String categoryselected) {
		this.categoryselected = categoryselected;
	}

	public String getTypeselected() {
		return typeselected;
	}

	public void setTypeselected(String typeselected) {
		this.typeselected = typeselected;
	}

	public String getGenderselected() {
		return genderselected;
	}

	public void setGenderselected(String genderselected) {
		this.genderselected = genderselected;
	}

	public String getSeasonselected() {
		return seasonselected;
	}

	public void setSeasonselected(String seasonselected) {
		this.seasonselected = seasonselected;
	}

	public Gender getGenderModel() {
		return genderModel;
	}

	public void setGenderModel(Gender genderModel) {
		this.genderModel = genderModel;
	}

	public Product_line getProductLine() {
		return productLine;
	}

	public void setProductLine(Product_line productLine) {
		this.productLine = productLine;
	}

	public Category getCategoryModel() {
		return categoryModel;
	}

	public void setCategoryModel(Category categoryModel) {
		this.categoryModel = categoryModel;
	}

	public Type getTypeModel() {
		return typeModel;
	}

	public void setTypeModel(Type typeModel) {
		this.typeModel = typeModel;
	}

	public Season getSeasonModel() {
		return seasonModel;
	}

	public void setSeasonModel(Season seasonModel) {
		this.seasonModel = seasonModel;
	}

	public String getDesignername() {
		return designername;
	}

	public void setDesignername(String designername) {
		this.designername = designername;
	}

	public Designer getDesigner() {
		return designer;
	}

	public void setDesigner(Designer designer) {
		this.designer = designer;
	}

	public List<String> getDesignerList() {
		return designerList;
	}

	public void setDesignerList(List<String> designerList) {
		this.designerList = designerList;
	}

	public String getTesting() {
		return testing;
	}

	public void setTesting(String testing) {
		this.testing = testing;
	}

	public List<Color> getColor() {
		return color;
	}

	public void setColor(List<Color> color) {
		this.color = color;
	}

	public int getSizeNo() {
		return sizeNo;
	}

	public void setSizeNo(int sizeNo) {
		this.sizeNo = sizeNo;
	}

	public int getColorNo() {
		return colorNo;
	}

	public void setColorNo(int colorNo) {
		this.colorNo = colorNo;
	}

	public int getPid() {
		return pid;
	}

	public void setPid(int pid) {
		this.pid = pid;
	}
	
}